int gettop(vector<int>& vv, int pos){
    if(vv[pos] != pos) 
        return gettop(vv,vv[pos]);
    else 
        return pos;
}
class Solution {
public:
   vector<int> findRedundantDirectedConnection(vector<vector<int>>& edges) {
       int size = edges.size();
       vector<int> vv(size + 1);
       for(int i = 1;i <= size;i++){
            vv[i] = i;
       }

        for(auto& e :edges){
            int first = e[0],second = e[1];
            int top_fist = gettop(vv,first),top_second = gettop(vv,second);
            if(top_fist != top_second)
                vv[top_fist] = top_second;
            else
                return e;
        }      
        return vector<int>{0,0};
    }
};